<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>

<style>

body{color:white ;
background-color:black;
font-size:19px;

}
/**/
img{
max-width:80%;
height:auto;
}

td#td0{
border-bottom:white 1px solid;
}

table{
border-collapse:collapse;
}  
  
</style>
<script>
document.write("<s"+"cript type='text/javascript' src='../Documents/data.js?"+Math.random()+"'></scr"+"ipt>");
</script>
<script type="text/javascript" src="browservariable.js">
</script>

 

<script language="javascript"> 
</script> 





<table id="abc" width = "100%"   border="0" style="table-layout:fixed; word-break:break-all; font-size:13px;" >
</table>




<script language="javascript">

//alert(variable);
    menustree = "menustree";
	 
	navigation = "YES";
	//setVariable("menutagnamecursor","shoujiyinhang")
    menutagname = getVariable("menutagnamecursor");
	
//	if(menutagname == null || menutagname.length <2){
//	   menutagname = "shoujiyinhang";
//	}
	 
  mainmenulist = getVariable(menustree);
if(mainmenulist == null){
 	xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET","menus.xml",false);
	xmlhttp.send();
	mainmenulist_all = xmlhttp.responseText;
	mainmenulist=mainmenulist_all;
	setVariable(menustree,mainmenulist);	
	mainmenulist = getVariable(menustree); 
 
}
/////////////////////////////////

  form = document.createElement("form");	
  form.innerHTML = mainmenulist;


  currentmenuelement = form.getElementsByTagName(menutagname)[0];
  //alert(currentmenuelement.attributes["title"].value);
  document.write("<card title='"+currentmenuelement.attributes["title"].value+"'/>");
  
  ES = currentmenuelement.getElementsByTagName("row");
  
  var loginway = getVariable("loginway");
  loginway = "loginway"+loginway;
  ESTEMP = new Array();
  var regist = 0;
  for(var i=0; i< ES.length;i++){
	if(ES[i].attributes[loginway]){
	   ESTEMP[regist] = ES[i];
	   regist++;
	}
  }
  ES = ESTEMP;


var storyinimgedingzhistr='';
function storyinimgesdingzhi(){

	
	var tableinner='';
	
	for (var i=0;i<ES.length;i++)
	{
		var flag = ES[i].attributes["check"].value;
		var src = ES[i].attributes["src"].value;
		var text = ES[i].attributes["text"].value;	
		var href = ES[i].attributes["href"].value;	
		var method = ES[i].attributes["method"].value;
		if( i%4 == 0){
		  storyinimgedingzhistr += "</tr><tr>";
		}
		  storyinimgedingzhistr += "<th href='";
		  storyinimgedingzhistr += href;
		  storyinimgedingzhistr += "' onClick='handlerdingzhi(this, ";
		  storyinimgedingzhistr += i;
		  storyinimgedingzhistr += ")'>";
		  storyinimgedingzhistr += "<img name='select'   src='select_32.png' check='";
		  storyinimgedingzhistr += flag;
		  storyinimgedingzhistr += "'/>";
		  storyinimgedingzhistr += "<img src='";
		  storyinimgedingzhistr += src;
		  storyinimgedingzhistr += "'/><br/>";
		  storyinimgedingzhistr += text;
		  storyinimgedingzhistr += "</th>";
	}

}	
function showinimagedingzhi(){
	var t = document.getElementById("abc");
	document.getElementById("abc").innerHTML = storyinimgedingzhistr;
	ths = document.getElementById("abc").getElementsByTagName("th");


	for(i=0;i<ths.length;i++){
	    imgs = ths[i].getElementsByTagName("img"); 
        imgs[0].style.position="absolute";
		if(imgs[0].attributes["check"].value=='Y'){
		   imgs[0].src="select_32.png";
		   
		}else{
		   imgs[0].src="disable_32.png";
		}
	}

}	

	


function handlerdingzhi(e ,index){

	    imgs = e.getElementsByTagName("img"); 
		
		if(imgs[0].attributes["check"].value=='Y'){
		   imgs[0].attributes["check"].value = 'N';
		}else{
		   imgs[0].attributes["check"].value = 'Y';
		}

		
		if(imgs[0].attributes["check"].value=='Y'){
		   imgs[0].src="select_32.png";
		}else{
		   imgs[0].src="disable_32.png";
		}
		
		ES[index].attributes["check"].value = imgs[0].attributes["check"].value;


	setVariable(menustree,form.innerHTML);
	mainmenulist = getVariable(menustree);

	storyinimagestr='';
	storyinimage();
	storyinliststr=''
	storyinlist();
	storyinimgedingzhistr='';
	storyinimgesdingzhi();
}


//////////image

var storyinimagestr='';
function storyinimage(){
    
		
	for (var i=0,j=0;i<ES.length;i++)
	{


		if(ES[i].attributes["check"].value == "Y"){

		
		  var src = ES[i].attributes["src"].value;
		  var text = ES[i].attributes["text"].value;	
		  var href = ES[i].attributes["href"].value;	
		  var method = ES[i].attributes["method"].value;
		


		
		
		  if( j%4 == 0){
	    	  storyinimagestr += "</tr><tr>";
	     	}
		  j++;
		  storyinimagestr += "<th href='";
		  storyinimagestr += href;
		  storyinimagestr += "' method='";
		  storyinimagestr += method;
		  
		if(ES[i].attributes["childmenutagname"]){
			storyinimagestr += "' childmenutagname='";
		    storyinimagestr += ES[i].attributes["childmenutagname"].value;
		}
		  
		  
		  storyinimagestr += "' onClick='loadhrefforlist(this)'>";
		  storyinimagestr += "<img src='";
		  storyinimagestr += src;
		  storyinimagestr += "'/><br/>";
		  storyinimagestr += text;
		  storyinimagestr += "</th>";
		}
	}
	
	

}

function showinimage(){
	var t = document.getElementById("abc");
	document.getElementById("abc").innerHTML = storyinimagestr;

}	




//////////list

var storyinliststr='';
function storyinlist(){
	for (var i=0;i<ES.length;i++)
	{
		if(ES[i].attributes["check"].value == "Y"){
		
		var src = ES[i].attributes["src"].value;
		var text = ES[i].attributes["text"].value;	
		var href = ES[i].attributes["href"].value;	
		var method = ES[i].attributes["method"].value;

		  storyinliststr += "<tr href='"
		  storyinliststr += href;
		  		
		if(ES[i].attributes["childmenutagname"]){
			storyinliststr += "' childmenutagname='";
		    storyinliststr += ES[i].attributes["childmenutagname"].value;
		}
		  
		  storyinliststr += "' onClick='loadhrefforlist(this)'><td width='20%' id='td0'><img src='";
		  storyinliststr += src;
		  storyinliststr += "'/>";
		  storyinliststr += "<td id='td0'>";
		  storyinliststr +=text
		  storyinliststr +="</td>";
		  storyinliststr += "<td width='15%' id='td0'> >>> </td></tr>";
		}

	}

}
	

function showinlist(){

	var t = document.getElementById("abc");
	document.getElementById("abc").innerHTML = storyinliststr;

}	
function loadhrefforlist(cur){

		if(cur.attributes["childmenutagname"]){
			setVariable("menutagnamecursor",cur.attributes["childmenutagname"].value);
		}

   var form = document.createElement("form");	
    form.setAttribute("method", "get");
    form.setAttribute("action",cur.attributes["href"].value);
    document.body.appendChild(form); 
    form.submit();
}

	
	storyinimage();
	storyinlist();
	storyinimgesdingzhi();
	


function grid_list_switchshow(){

    v = "缩略图";
	if(currentmenuelement.attributes["showway"].value =='list'){
	   showinimage();
	   currentmenuelement.attributes["showway"].value='grid';
	   
	}else{
	   showinlist();
	   currentmenuelement.attributes["showway"].value='list';
	   v = "列表"
	}
	setVariable(menustree,form.innerHTML);
	return v;
}

function setrightBarButtonItem(){
     v = "列表";
	if(currentmenuelement.attributes["showway"].value =='grid'){
	   v = "缩略图"
	}
	return v;
   
}

if(currentmenuelement.attributes["showway"].value=='list'){
       showinlist();
}else{
	   showinimage();
}


function viewwillappear(v){ 

	mainmenulist = getVariable(menustree);
	form = document.createElement("form");	
	form.innerHTML = mainmenulist;
	currentmenuelement = form.getElementsByTagName(menutagname)[0];
	ES = currentmenuelement.getElementsByTagName("row");
	//alert(variable);
}
</script>	


